#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
const double PI = acos(-1.0);
const int MAX = 100005;
char A[MAX], B[MAX];

struct Virt{
	double r, i;
	Virt(double r = 0.0, double i = 0.0){
		this->r = r;
		this->i = i;
	}
	Virt operator + (const Virt &x){
		return Virt(r + x.r, i + x.i);
	}
	Virt operator - (const Virt &x){
		return Virt(r - x.r, i - x.i);
	}
	Virt operator * (const Virt &x){
		return Virt(r * x.r - i * x.i, i * x.r + r * x.i);
	}
};
Virt AA[MAX], BB[MAX];

void Reader(Virt F[], int len){
	int j = len>>1;
	for(int i=1;i<len-1;i++){
		if(i < j){
			swap(F[i], F[j]);
		}
		int k = len>>1;
		while(j >= k){
			j -= k;
			k >>= 1;
		}
		if(j < k){
			j += k;
		}
	}
}

void FFT(Virt F[], int len, int on){
	Reader(F, len);
	for(int h=2;h<=len;h<<=1){
		Virt wn(cos(-on*2*PI/h), sin(-on*2*PI/h));
		for(int j=0;j<len;j+=h){
			Virt w(1, 0);
			for(int k=j;k<j+h/2;k++){
				Virt u = F[k];
				Virt t = w * F[k+h/2];
				F[k] = u+t;
				F[k+h/2] = u-t;
				w = w * wn;
			}
		}
	}
	if(on == -1){
		for(int i=0;i<len;i++){
			F[i].r /= len;
		}
	}
}

void Conv(Virt a[], Virt b[], int len){
	FFT(a, len, 1);
	FFT(b, len, 1);
	for(int i=0;i<len;i++){
		a[i] = a[i] * b[i];
	}
	FFT(a, len, -1);
}

int main(){
	int t;
	scanf("%d", &t);
	while(t--){
		scanf("%s %s", A, B);
		int lena = strlen(A);
		int lenb = strlen(B);
		for(int i=0;i<lena;i++){
			AA[i].r = A[lena - 1 - i] - '0';
			AA[i].i = i;
		}
		for(int i=0;i<lenb;i++){
			BB[i].r = B[lenb - 1 - i] - '0';
			BB[i].i = i;
		}
		int len;
		for(len = 1; len < lena + lenb; len<<=1);
		Conv(AA, BB, len);
		
		bool flag = false;
		int cnt = 0;
		for(int i=len-1;i>=0;i--){
			if(AA[i].r != 0){
				flag = true;
				A[i + 1] = '\0';
			}
			if(flag){
				A[cnt++] = AA[i].r + '0';
			}
		}
		printf("%s\n", A);
	}
	return 0;
}
